package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.CouponCustomerVo;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2024/3/2  11:10
 * @Description:添加优惠礼包的详情的适配器逻辑，内部包裹的是优惠券的小布局逻辑
 */
public class CardCouponPackAdapter extends BaseQuickAdapter<CouponCustomerVo, BaseViewHolder> {

    public CardCouponPackAdapter(int layoutResId, @Nullable List<CouponCustomerVo> data) {
        super(layoutResId, data);

        addChildClickViewIds(R.id.roundtextviewsingledetail);

    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, CouponCustomerVo couponCustomerVo) {

        if (couponCustomerVo != null) {

            //优惠券的类型 是短类型的布局
            String name = couponCustomerVo.getCouponTypeInfo();

            //优惠的金额展示的 价格标题（价格或者折扣）
            String couponInfo = couponCustomerVo.getCouponInfo();

            //优惠券的优惠金额
//            BigDecimal bigDecimal = couponCustomerVo.getCouponAmount();//couponAmount

//            String balancePriceString = "";
//
//            if (bigDecimal != null) {
//                //去掉小数点的内容
//                balancePriceString = CommUtils.formatRemoveDotAfter(bigDecimal).toString();//bigDecimal.toString();
//            } else {
//                balancePriceString = CommUtils.formatComma2BigDecimal(CommUtils.valueOf(0.00)).toString();
//            }


            //其他信息 ？
            //优惠券的名称
            TextView textViewCouponPackName = (TextView) baseViewHolder.getView(R.id.textviewcouponpackname);
            //优惠券的优惠金额
            TextView textViewMoney = (TextView) baseViewHolder.getView(R.id.textviewmoney);
            //
//            RoundTextView roundTextViewAuthHasContacted = (RoundTextView) baseViewHolder.getView(R.id.roundtextviewsingledetail);

            CommUtils.setText(textViewCouponPackName, name);
            //价格 保留小数点？
            CommUtils.setText(textViewMoney, couponInfo);

        }

    }
}
